class STACK:
    def __init__(self):
        self.data = []
        self.__mindata = []
    '''
    辅助栈
    '''
    def __minempty(self):
        if len(self.__mindata) == 0:
            return True
        return False
    
    def __minpush(self, e):
        self.__mindata.append(e)

    def __minpop(self):
        assert not self.__minempty()#assert 后边的语句为True才会继续执行
        return self.__mindata.pop()
    
    def __mingettop(self):
        assert not self.__minempty()
        return self.__mindata[-1]
    '''
    主栈
    '''
    def empty(self):
        if len(self.data) == 0:
            return True
        return False
    
    def push(self, e):
        if self.empty() or e <= self.Getmin():
            self.__minpush(e)
        self.data.append(e)
    def pop(self):
        assert not self.empty()
        if self.data[-1] == self.__mingettop():
            self.__minpop()
        return self.data.pop()
    
    def gettop(self):
        assert not self.empty()
        return self.data[-1]
    
    def Getmin(self):
        return self.__mingettop()
    
if __name__ == "__main__":
    sta = STACK()
    num_list = [1, 2, 3, 0, -1, 2]
    i = 0
    while i < len(num_list):
        sta.push(num_list[i])
        i += 1
    while not sta.empty():
        print("min:", sta.Getmin())
        sta.pop()
